<?php
class Zendme_Models_Inbox extends Zend_Db_Table{

	protected $_name = 'inbox';
	protected $_primary = 'id';
	
	public function listItem($arrParam = null, $options = null)
	{
		if($options['task']=='admin-list')
		{
			$result=$this->fetchAll()->toArray();
		}		
		return $result;
	}
	
	public function getItem($arrParam=null,$options=null)
	{
		if($options['task']=="admin")
		{
			$select=$this->select()
						 ->where('id=?',$arrParam['id']);
			$result= $this->fetchRow($select)->toArray();						 
		}
			
		return $result;
	}
	
	public function deleteItem($arrParam=null,$options=null)
	{
		if($options['task'] == 'admin-delete'){
			$where = ' id = ' . $arrParam['id'];
			$this->delete($where);
		}		
	}

	
	public function saveItem($arrParam = null,$options = null){	
		$row=$this->fetchNew();
		$row->name 			= $arrParam['name'];
		$row->email 		= $arrParam['email'];
		$row->content 		= $arrParam['content'];
		$row->ip 			= $_SERVER[REMOTE_ADDR];	
		$row->save();	
	}
		
}